﻿@model Think9.Models.TbBasicEntity
@{ ViewBag.Title = "Index";
    Layout = "~/Areas/Shared/_LayuiForm.cshtml"; }

<form class="layui-form" lay-filter="formEdit">
    <input style="display: none" name="TbId" id="TbId" value="@Model.TbId">
    <fieldset class="table-fieldset" id="field2">
        <legend style="color:darkgrey">List页面</legend>
        <div style="margin: 10px 10px 10px 10px">
            <div class="layui-form-item" id="top01">
                <label class="layui-form-label"></label>
                <div class="layui-input-inline">
                    是否显示
                </div>
                <div class="layui-input-inline">
                    按钮标题
                </div>
                <div class="layui-input-inline">
                    其他
                </div>
                <div class="layui-input-inline">
                    权限设置
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">详细按钮</label>
                <div class="layui-input-inline">
                    <input type="checkbox" name="ButListDetails" id="ButListDetails" lay-filter="ButListDetails" lay-skin="primary" title="显示" value="1">
                </div>
                <div class="layui-input-inline">
                    <input type="text" name="ButListDetailsTxt" id="ButListDetailsTxt" placeholder="按钮标题" autocomplete="off" class="layui-input" style="width:100px" maxlength="10" readonly>
                </div>
                <div class="layui-input-inline">
                    <select id="ButListDetailsExa" name="ButListDetailsExa" lay-filter="selectfilter">
                        <option value="select">打开弹出页面</option>
                        <option value="html">打开网页</option>
                        <option value="pdf">打开pdf</option>
                    </select>
                </div>
                <div class="layui-input-inline">
                    <button type="button" class="layui-btn" id="_ButListDetails"><i class="fa fa-edit"></i></button>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">记录按钮</label>
                <div class="layui-input-inline">
                    <input type="checkbox" name="ButListRecord" id="ButListRecord" lay-skin="primary" title="显示" value="1">
                </div>
                <div class="layui-input-inline">
                    <input type="text" name="ButListRecordTxt" id="ButListRecordTxt" placeholder="按钮标题" autocomplete="off" class="layui-input" style="width:100px" maxlength="10" readonly>
                </div>
                <div class="layui-input-inline">
                    <span>&nbsp;</span>
                </div>
                <div class="layui-input-inline">
                    <button type="button" class="layui-btn" id="_ButListRecord"><i class="fa fa-edit"></i></button>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">编辑按钮</label>
                <div class="layui-input-inline">
                    <input type="checkbox" name="ButListEdit" id="ButListEdit" lay-skin="primary" title="显示" value="1" disabled="disabled">
                </div>
                <div class="layui-input-inline">
                    <input type="text" name="ButListEditTxt" id="ButListEditTxt" placeholder="按钮标题" autocomplete="off" class="layui-input" style="width:100px" maxlength="10" readonly>
                </div>
                <div class="layui-input-inline">
                    <span>&nbsp;</span>
                </div>
                <div class="layui-input-inline">
                    <button type="button" class="layui-btn" id="_ButListEdit"><i class="fa fa-edit"></i></button>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">删除按钮</label>
                <div class="layui-input-inline">
                    <input type="checkbox" name="ButListDel" id="ButListDel" lay-skin="primary" title="显示" value="1" disabled="disabled">
                </div>
                <div class="layui-input-inline">
                    <input type="text" name="ButListDelTxt" id="ButListDelTxt" placeholder="按钮标题" autocomplete="off" class="layui-input" style="width:100px" maxlength="10" readonly>
                </div>
                <div class="layui-input-inline">
                    <span>&nbsp;</span>
                </div>
                <div class="layui-input-inline">
                    <button type="button" class="layui-btn" id="_ButListDel"><i class="fa fa-edit"></i></button>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">新增按钮</label>
                <div class="layui-input-inline">
                    <input type="checkbox" name="ButListADD" id="ButListADD" lay-skin="primary" title="显示" value="1" disabled="disabled">
                </div>
                <div class="layui-input-inline">
                    <input type="text" name="ButListADDTxt" id="ButListADDTxt" placeholder="按钮标题" autocomplete="off" class="layui-input" style="width:100px" maxlength="10" >
                </div>
                <div class="layui-input-inline">
                    <span>&nbsp;</span>
                </div>
                <div class="layui-input-inline">
                    <button type="button" class="layui-btn" id="_ButListADD"><i class="fa fa-edit"></i></button>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">批量删除</label>
                <div class="layui-input-inline">
                    <input type="checkbox" name="ButListBatchDel" id="ButListBatchDel" lay-skin="primary" title="显示" value="1">
                </div>
                <div class="layui-input-inline">
                    <input type="text" name="ButListBatchDelTxt" id="ButListBatchDelTxt" placeholder="按钮标题" autocomplete="off" class="layui-input" style="width:100px" maxlength="10" readonly>
                </div>
                <div class="layui-input-inline">
                    <span>&nbsp;</span>
                </div>
                <div class="layui-input-inline">
                    <button type="button" class="layui-btn" id="_ButListBatchDel"><i class="fa fa-edit"></i></button>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">数据导入</label>
                <div class="layui-input-inline">
                    <input type="checkbox" name="ButListImportExcel" id="ButListImportExcel" lay-skin="primary" title="显示" value="1">
                </div>
                <div class="layui-input-inline">
                    <input type="text" name="ButListImportExcelTxt" id="ButListImportExcelTxt" placeholder="按钮标题" autocomplete="off" class="layui-input" style="width:100px" maxlength="10" readonly>
                </div>
                <div class="layui-input-inline">
                    <span>&nbsp;</span>
                </div>
                <div class="layui-input-inline">
                    <button type="button" class="layui-btn" id="_ButListImportExcel"><i class="fa fa-edit"></i></button>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">合并导出</label>
                <div class="layui-input-inline">
                    <input type="checkbox" name="ButListMergeExport" id="ButListMergeExport" lay-skin="primary" title="显示" value="1">
                </div>
                <div class="layui-input-inline">
                    <input type="text" name="ButListMergeExportTxt" id="ButListMergeExportTxt" placeholder="按钮标题" autocomplete="off" class="layui-input" style="width:100px" maxlength="10" readonly>
                </div>
                <div class="layui-input-inline">
                    <span>&nbsp;</span>
                </div>
                <div class="layui-input-inline">
                    <button type="button" class="layui-btn" id="_ButListMergeExport"><i class="fa fa-edit"></i></button>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">流程查看</label>
                <div class="layui-input-inline">
                    <input type="checkbox" name="ButListPrcs" id="ButListPrcs" lay-skin="primary" title="显示" value="1">
                </div>
                <div class="layui-input-inline">
                    <input type="text" name="ButListPrcsTxt" id="ButListPrcsTxt" placeholder="按钮标题" autocomplete="off" class="layui-input" style="width:100px" maxlength="10" readonly>
                </div>
                <div class="layui-input-inline">
                    <span>&nbsp;</span>
                </div>
                <div class="layui-input-inline">
                    <button type="button" class="layui-btn" id="_ButListPrcs"><i class="fa fa-edit"></i></button>
                </div>
            </div>
        </div>
    </fieldset>
    <br />
    <fieldset class="table-fieldset" id="field">
        <legend style="color:darkgrey">Form页面</legend>
        <div style="margin: 10px 10px 10px 10px">
            <div class="layui-form-item" id="top02">
                <label class="layui-form-label"></label>
                <div class="layui-input-inline">
                    是否显示
                </div>
                <div class="layui-input-inline">
                    按钮标题
                </div>
                <div class="layui-input-inline">
                    提示字符
                </div>
                <div class="layui-input-inline">
                    权限设置
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-form-item">
                    <label class="layui-form-label">打印按钮</label>
                    <div class="layui-input-inline">
                        <input type="checkbox" name="ButPrint" id="ButPrint" lay-skin="primary" title="显示" value="1">
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" name="ButPrintTxt" id="ButPrintTxt" placeholder="按钮标题" autocomplete="off" class="layui-input" style="width:100px" maxlength="10">
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" name="ButPrintWarn" id="ButPrintWarn" placeholder="点击按钮后弹出提示字符" autocomplete="off" class="layui-input" maxlength="120" readonly>
                    </div>
                    <div class="layui-input-inline">
                        <button type="button" class="layui-btn" id="_ButPrint"><i class="fa fa-edit"></i></button>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-form-item">
                    <label class="layui-form-label">附件按钮</label>
                    <div class="layui-input-inline">
                        <input type="checkbox" name="ButAtt" id="ButAtt" lay-skin="primary" title="显示" value="1">
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" name="ButAttTxt" id="ButAttTxt" placeholder="按钮标题" autocomplete="off" class="layui-input" style="width:100px" maxlength="10">
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" name="ButAttWarn" id="ButAttWarn" placeholder="点击按钮后弹出提示字符" autocomplete="off" class="layui-input" maxlength="120" readonly>
                    </div>
                    <div class="layui-input-inline">
                        <button type="button" class="layui-btn" id="_ButAtt"><i class="fa fa-edit"></i></button>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-form-item">
                    <label class="layui-form-label">保存按钮</label>
                    <div class="layui-input-inline">
                        <input type="checkbox" name="ButEdit" id="ButEdit" lay-skin="primary" title="显示" value="1" disabled="disabled">
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" name="ButEditTxt" id="ButEditTxt" placeholder="按钮标题" autocomplete="off" class="layui-input" style="width:100px" maxlength="10">
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" name="ButEditWarn" id="ButEditWarn" placeholder="点击按钮后弹出提示字符" autocomplete="off" class="layui-input" maxlength="120">
                    </div>
                    <div class="layui-input-inline">
                        <button type="button" class="layui-btn" id="_ButEdit"><i class="fa fa-edit"></i></button>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-form-item">
                    <label class="layui-form-label">转交按钮</label>
                    <div class="layui-input-inline">
                        <input type="checkbox" name="ButNext" id="ButNext" lay-skin="primary" title="显示" value="1">
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" name="ButNextTxt" id="ButNextTxt" placeholder="按钮标题" autocomplete="off" class="layui-input" style="width:100px" maxlength="10">
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" name="ButNextWarn" id="ButNextWarn" placeholder="点击按钮后弹出提示字符" autocomplete="off" class="layui-input" maxlength="120">
                    </div>
                    <div class="layui-input-inline">
                        <button type="button" class="layui-btn" id="_ButNext"><i class="fa fa-edit"></i></button>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-form-item">
                    <label class="layui-form-label">结束按钮</label>
                    <div class="layui-input-inline">
                        <input type="checkbox" name="ButFinish" id="ButFinish" lay-skin="primary" title="显示" value="1">
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" name="ButFinishTxt" id="ButFinishTxt" placeholder="按钮标题" autocomplete="off" class="layui-input" style="width:100px" maxlength="10">
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" name="ButFinishWarn" id="ButFinishWarn" placeholder="点击按钮后弹出提示字符" autocomplete="off" class="layui-input" maxlength="120">
                    </div>
                    <div class="layui-input-inline">
                        <button type="button" class="layui-btn" id="_ButFinish"><i class="fa fa-edit"></i></button>
                    </div>
                </div>
            </div>
        </div>
    </fieldset>
    <br />
    <fieldset class="table-fieldset" id="field3">
        <legend style="color:darkgrey">Detail页面</legend>
        <div style="margin: 10px 10px 10px 10px">
            <div class="layui-form-item" id="top03">
                <label class="layui-form-label"></label>
                <div class="layui-input-inline">
                    是否显示
                </div>
                <div class="layui-input-inline">
                    按钮标题
                </div>
                <label class="layui-form-label"></label>
                <div class="layui-input-inline">
                    是否显示
                </div>
                <div class="layui-input-inline">
                    按钮标题
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-form-item">
                    <label class="layui-form-label">查看PDF</label>
                    <div class="layui-input-inline">
                        <input type="checkbox" name="ButPDFDetails" id="ButPDFDetails" lay-skin="primary" title="显示" value="1">
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" name="ButPDFDetailsTxt" id="ButPDFDetailsTxt" placeholder="按钮标题" autocomplete="off" class="layui-input" style="width:100px" maxlength="10" readonly>
                    </div>
                    <label class="layui-form-label">查看Excel</label>
                    <div class="layui-input-inline">
                        <input type="checkbox" name="ButExcelDetails" id="ButExcelDetails" lay-skin="primary" title="显示" value="1">
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" name="ButExcelDetailsTxt" id="ButExcelDetailsTxt" placeholder="按钮标题" autocomplete="off" class="layui-input" style="width:100px" maxlength="10" readonly>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-form-item">
                    <label class="layui-form-label">查看DOC</label>
                    <div class="layui-input-inline">
                        <input type="hidden" name="ButDOCDetails" value="0">
                        <input type="checkbox" name="ButDOCDetails" id="ButDOCDetails" lay-skin="primary" title="显示" value="1">
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" name="ButDOCDetailsTxt" id="ButDOCDetailsTxt" placeholder="按钮标题" autocomplete="off" class="layui-input" style="width:100px" maxlength="10" readonly>
                    </div>
                    <label class="layui-form-label">附件按钮</label>
                    <div class="layui-input-inline">
                        <input type="checkbox" name="ButAttDetails" id="ButAttDetails" lay-skin="primary" title="显示" value="1">
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" name="ButAttDetailsTxt" id="ButAttDetailsTxt" placeholder="按钮标题" autocomplete="off" class="layui-input" style="width:100px" maxlength="10" readonly>
                    </div>
                </div>
            </div>
        </div>
    </fieldset>
    <br />
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="edit">编 辑</button>
        </div>
    </div>
</form>

<script>
	layui.use(["table", 'form', "exLayer", "exUtils"], function () {
		let form = layui.form;
		let exLayer = layui.exLayer;
		let exUtils = layui.exUtils;
		let table = layui.table;

		let $ = layui.$;
		form.render();

		getFormVal();

		form.val("formEdit", {

			//form页面
            "ButAttTxt": "@Model.ButAttTxt"
            ,"ButPrintTxt": "@Model.ButPrintTxt"
			,"ButEditTxt": "@Model.ButEditTxt"
			,"ButNextTxt": "@Model.ButNextTxt"
			,"ButFinishTxt": "@Model.ButFinishTxt"
			,"ButAttWarn": "@Model.ButAttWarn"
            ,"ButPrintWarn": "@Model.ButPrintWarn"
            ,"ButEditWarn": "@Model.ButEditWarn"
			,"ButNextWarn": "@Model.ButNextWarn"
			,"ButFinishWarn": "@Model.ButFinishWarn"

			//list页面
            ,"ButListDetailsExa": "@Model.ButListDetailsExa"
			,"ButListDetailsTxt": "@Model.ButListDetailsTxt"
			,"ButListRecordTxt": "@Model.ButListRecordTxt"
			,"ButListEditTxt": "@Model.ButListEditTxt"
			,"ButListDelTxt": "@Model.ButListDelTxt"
            ,"ButListADDTxt": "@Model.ButListADDTxt"
            ,"ButListImportExcelTxt": "数据导入"
            ,"ButListBatchDelTxt": "批量删除"
            ,"ButListMergeExportTxt": "合并导出"
            ,"ButListPrcsTxt": "显示流程步骤"

			//Details页面
			,"ButPDFDetailsTxt": "@Model.ButPDFDetailsTxt"
			,"ButExcelDetailsTxt": "@Model.ButExcelDetailsTxt"
			,"ButDOCDetailsTxt": "@Model.ButDOCDetailsTxt"
			,"ButAttDetailsTxt": "@Model.ButAttDetailsTxt"

		});

		function getFormVal() {
			if (@Model.ButPrint == "1") {
                $('#ButPrint').attr("checked", true);
			}
			else {
                $("#ButPrint").removeAttr("checked");
            }

            if (@Model.ButAtt == "1") {
				$('#ButAtt').attr("checked", true);
			}
			else {
				$("#ButAtt").removeAttr("checked");
			}

			if (@Model.ButNext == "1") {
				$('#ButNext').attr("checked", true);
			}
			else {
				$("#ButNext").removeAttr("checked");
			}

			if (@Model.ButFinish == "1") {
				$('#ButFinish').attr("checked", true);
			}
			else {
				$("#ButFinish").removeAttr("checked");
			}

			$('#ButEdit').attr("checked", true);

			$('#ButListEdit').attr("checked", true);
			$('#ButListDel').attr("checked", true);
			$('#ButListADD').attr("checked", true);

			if (@Model.ButListDetails == "1") {
				$('#ButListDetails').attr("checked", true);
			}
			else {
				$("#ButListDetails").removeAttr("checked");
			}

			if (@Model.ButListRecord == "1") {
				$('#ButListRecord').attr("checked", true);
			}
			else {
				$("#ButListRecord").removeAttr("checked");
			}

			if (@Model.ButPDFDetails == "1") {
				$('#ButPDFDetails').attr("checked", true);
			}
			else {
				$("#ButPDFDetails").removeAttr("checked");
			}

			if (@Model.ButExcelDetails == "1") {
				$('#ButExcelDetails').attr("checked", true);
			}
			else {
				$("#ButExcelDetails").removeAttr("checked");
			}

			if (@Model.ButDOCDetails == "1") {
				$('#ButDOCDetails').attr("checked", true);
			}
			else {
				$("#ButDOCDetails").removeAttr("checked");
			}

			if (@Model.ButAttDetails == "1") {
				$('#ButAttDetails').attr("checked", true);
			}
			else {
				$("#ButAttDetails").removeAttr("checked");
            }

            if (@Model.ButListImportExcel == "1") {
                $('#ButListImportExcel').attr("checked", true);
			}
			else {
                $("#ButListImportExcel").removeAttr("checked");
            }

            if (@Model.ButListBatchDel == "1") {
                $('#ButListBatchDel').attr("checked", true);
			}
			else {
                $("#ButListBatchDel").removeAttr("checked");
            }

            if (@Model.ButListMergeExport == "1") {
                $('#ButListMergeExport').attr("checked", true);
			}
			else {
                $("#ButListMergeExport").removeAttr("checked");
            }

            var _fwid = "@Model.FlowId";
            if (_fwid.startsWith('bi_')) {
                $("#ButListPrcs").removeAttr("checked");
                $('#ButListPrcs').attr('disabled', 'disabled');
            }
            else {
              if (@Model.ButListPrcs == "1") {
                $('#ButListPrcs').attr("checked", true);
			   }
			   else {
                 $("#ButListPrcs").removeAttr("checked");
			   }
            }
		}

		form.on("submit(edit)", function (data) {
			var _list = [];
			getControl(_list);

			exUtils.ajax("/SysTable/TbBasic/EditTbBut", "post", { entity: data.field, tbid: $("#TbId").val(), "list": _list }, true).done(function (response) {
				exLayer.greenTickMsg(response.message, function () {
					parent.layer.close(parent.layer.getFrameIndex(window.name));
				});
			}).fail(function (error) {
				console.log(error);
			});
			return false;
        });

        //从控件读值
        function getControl(_list) {
            _list.push({ Text: 'print', Value: $('#ButPrint').prop('checked') });
            _list.push({ Text: 'att', Value: $('#ButAtt').prop('checked') });
            _list.push({ Text: 'next', Value: $('#ButNext').prop('checked') });
            _list.push({ Text: 'finish', Value: $('#ButFinish').prop('checked') });
            _list.push({ Text: 'listdetails', Value: $('#ButListDetails').prop('checked'), Exa: $('#ButListDetailsExa').val() });
            _list.push({ Text: 'listrecord', Value: $('#ButListRecord').prop('checked') });
            _list.push({ Text: 'pdfdetails', Value: $('#ButPDFDetails').prop('checked') });
            _list.push({ Text: 'exceldetails', Value: $('#ButExcelDetails').prop('checked') });
            _list.push({ Text: 'docdetails', Value: $('#ButDOCDetails').prop('checked') });
            _list.push({ Text: 'attdetails', Value: $('#ButAttDetails').prop('checked') });

            _list.push({ Text: 'listimportexcel', Value: $('#ButListImportExcel').prop('checked') });
            _list.push({ Text: 'listbatchdel', Value: $('#ButListBatchDel').prop('checked') });
            _list.push({ Text: 'listmergeexport', Value: $('#ButListMergeExport').prop('checked') });
            _list.push({ Text: 'listprcs', Value: $('#ButListPrcs').prop('checked') });
        }

        function openMiddle(title, butid, pageType) {
            exLayer.openMiddle(title + " - 按钮权限", "/SysTable/TbBasic/TbButDisable?tbid=" + $("#TbId").val() + "&butid=" + butid + "&pageType=" + pageType, '600px', '400px', layui.device().mobile);
        }
        //记录
        $('#_ButListRecord').on('click', function () {
            openMiddle('record', 'record', 'list');
        });
        //查看详细
        $('#_ButListDetails').on('click', function () {
            openMiddle('detail', 'detail',  'list');
        });
        //编辑
        $('#_ButListEdit').on('click', function () {
            openMiddle('edit', 'edit', 'list');
        });
        //删除
        $('#_ButListDel').on('click', function () {
            openMiddle('del', 'del', 'list');
        });
        //新增数据
        $('#_ButListADD').on('click', function () {
            openMiddle('add', 'add', 'list');
        });
        //批量删除
        $('#_ButListBatchDel').on('click', function () {
            openMiddle('batchDel', 'batchDel',  'list');
        });
        //导入数据
        $('#_ButListImportExcel').on('click', function () {
            openMiddle('importExcel', 'importExcel','list');
        });
        //合并导出
        $('#_ButListMergeExport').on('click', function () {
            openMiddle('mergeExport', 'mergeExport','list');
        });
        //流程查看
        $('#_ButListPrcs').on('click', function () {
            openMiddle('listprcs', 'listprcs', 'list');
        });

        //
        $('#_ButPrint').on('click', function () {
            openMiddle('print', 'print','form');
        });
        //
        $('#_ButAtt').on('click', function () {
            openMiddle('att', 'att','form');
        });
        //
        $('#_ButEdit').on('click', function () {
            openMiddle('edit', 'edit','form');
        });
        //
        $('#_ButNext').on('click', function () {
            openMiddle('next', 'next', 'form');
        });
        //
        $('#_ButFinish').on('click', function () {
            openMiddle('finish', 'finish', 'form');
        });

        $(document).ready(function () {
            if (layui.device().mobile) {
                $("#top01").attr("style", "display:none");
                $("#top02").attr("style", "display:none");
                $("#top03").attr("style", "display:none");
            }
        });
	})
</script>